<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of LangSelector
 *
 * @author khavu
 */
class Australian_Controller_Plugin_LangSelector extends Zend_Controller_Plugin_Abstract {

    function preDispatch(\Zend_Controller_Request_Abstract $request) {

        $lang = $request->getParam('lang', '');
        if ($lang !== 'en' && $lang !== 'vi') {
            $request->setParam('lang', 'en');
        }
        $lang = $request->getParam('lang');
        if ($lang == 'en') {
            $locale = 'en_US';
        } else {
            $locale = 'vi_VN';
        }
        $zendLocale = new Zend_Locale();
        $zendLocale->setLocale($locale);
        Zend_Registry::set('Zend_Locale', $zendLocale);
        $translate = new Zend_Translate('csv', APPLICATION_PATH . '/configs/lang/' . $lang . '.csv');
        Zend_Registry::set('Zend_Translate', $translate);
    }

}

?>
